package me.tuyou.function.iterate;

import org.apache.flink.api.java.DataSet;
import org.apache.flink.api.java.ExecutionEnvironment;
import org.apache.flink.api.java.operators.IterativeDataSet;
import org.apache.flink.api.java.operators.MapOperator;

/**
 * 批处理的全量迭代
 */
public class BulkIterateTest {
    public static void main(String[] args) throws Exception {
        ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
        IterativeDataSet<Integer> iterate = env.fromElements(0, 10)
                //迭代10次
                .iterate(10);
        MapOperator<Integer, Integer> map = iterate.map(i -> i + 1);
        DataSet<Integer> output = iterate.closeWith(map);
        output.print();
    }
}
